﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace Charisma
{
    public class ConfigurationRegistry
    {
        internal IndexedSet<string, RepositoryConfigurator> Repositories;
        internal IndexedSet<Type, EntityConfigurator> Entities;

        public ConfigurationRegistry Add<T>(EntityConfigurator<T> configurator)
        {
            Contract.Requires(configurator != null);

            Entities.Add(configurator);
            return this;
        }

        public ConfigurationRegistry Add<T>(RepositoryConfigurator<T> configurator)
        {
            Contract.Requires(configurator != null);

            Repositories.Add(configurator);
            return this;
        }

        public ConfigurationRegistry()
        {
            Repositories = new IndexedSet<string, RepositoryConfigurator>(c => c.MemberName);
            Entities = new IndexedSet<Type, EntityConfigurator>(c => c.EntityType);
        }
    }
}
